# -- coding:utf-8 --
names = ['tuliang','xushaopeng','lichao']
print(names)

# 1 错误的添加元素
# names[3] = 'zhangsan'
print(names)

# 2 正确的添加元素
# 2.1 在尾部添加元素
print("\n 2.1 在尾部添加元素******************")
print("ames.append('zhangsan')")
names.append('zhangsan')
print(names)

# 2.2 指定位置插入元素
print("\n2.2 指定位置插入元素******************")
print("names.insert(0,'TUL')")
names.insert(0,'TUL')
print(names)

# 3.1 列表中删除元素
print("\n3.1 列表中删除元素******************")
print("del names[0]")
del names[0]
print(names)

# 3.2 pop删除元素,弹出尾部元素
print("\n3.2 pop删除元素,弹出尾部元素******************")
print("name = names.pop()")
name = names.pop()
print(name)
print(names)

# 3.3 根据值删除元素
print("\n3.3 根据值删除元素******************")
print("names.remove('lichao')")
names.remove('lichao')
print(names)

# 4.1 排序
print("\n 4.1 排序(永久排序)******************")
names = ['tuliang','xushaopeng','lichao']
print(names)
print(" names.sort()")
names.sort()
print(names)

# 4.2 排序:倒叙
print("\n 4.2 排序:倒叙******************")
names = ['tuliang','xushaopeng','lichao']
print(names)
print(" names.sort(reserve=True)")
names.sort(reverse=True)
print(names)

print(" names.reverse()")
names.reverse()
print(names)

# 4.3 排序(临时排序)
print("\n 4.3 排序(临时排序)******************")
names = ['tuliang','xushaopeng','lichao']
print(names)
print(" sorted(names)")
print(sorted(names))
print(names)

# 4.4 确定列表长度
print("\n 4.4 确定列表长度******************")
names = ['tuliang','xushaopeng','lichao']
print(names)

print("len=" + str(len(names)))